<!--
 * @Author: qinglong
 * @Date: 2021-04-29 15:16:12
 * @LastEditors: qinglong
 * @LastEditTime: 2021-05-19 13:50:26
 * @FilePath: \systemCenter\src\views\ftpManage\positionManage\amend\positionAmendIndex.vue
 * @Description: 
-->
<template>
  <!--  数据补录页面 -->
  <div class="positionAmendPage">
    <!-- 按钮与搜索 -->
    <el-row class="positionAmend container">
      <el-col style="margin-right:10px;" class="content-left">
        <!-- 操作区域 -->
        <upper-template
          exportIcon
          importIcon
          @search="searchFunc()"
          @clear="
            (searchForm.acctNo = '')
          "
        >
          <!-- 操作按钮区 -->
          <template slot="buttonArea">
            <el-button @click="addOrEditFunc('1')">新增</el-button>
            <el-button @click="addOrEditFunc('2')">编辑</el-button>
            <el-button @click="delFunc()">删除</el-button>
            <el-button @click="addOrEditFunc('3')">查看</el-button>
            <el-button @click="catHistory()">查看历史</el-button>
          </template>

          <div slot="exportArea">
            <!-- 导出操作区域 -->
            <el-button @click="exportExcel('1')">导出模板</el-button>
            <el-button @click="exportExcel('2')">导出数据</el-button>
          </div>
          <!-- 导入 -->
          <div slot="importArea">
            <!-- 导入操作区域 -->
            <el-upload
              accept=".xls, .xlsx"
              ref="upload"
              :multiple="false"
              :before-upload="beforeUpload"
              :show-file-list="false"
              action
              :limit="1"
              :http-request="uploadFile"
            >
              <el-button>导入</el-button>
            </el-upload>
          </div>
          <!-- 搜索区 -->
          <template slot="searchArea">
            <el-form
              :model="searchForm"
              ref="searchForm"
              label-width="80px"
              label-position="right"
              size="mini"
            >
              <el-form-item label="账号: ">
                <el-input v-model="searchForm.acctNo"></el-input>
              </el-form-item>
            </el-form>
          </template>
          <!-- 显示隐藏区 -->
          <template slot="columnHide">
            <el-checkbox-group v-model="checkList">
              <el-checkbox
                v-for="item in textData"
                :label="item.label"
                :key="item.prop"
                :checked="item.checked"
              >{{ item.label }}</el-checkbox>
            </el-checkbox-group>
          </template>
        </upper-template>
        <!-- 列表 -->

        <el-table
          :header-cell-style="{ 'white-space': 'nowrap', width: 'auto' }"
          ref="multipleTable"
          :data="tableData"
          @row-click="rowChecked"
        >
          <el-table-column width="55" type="selection"></el-table-column>
          <el-table-column prop="acctNo" label="账号" v-if="columnState[0]" show-overflow-tooltip></el-table-column>
          <el-table-column prop="dataDt" label="数据日期" v-if="columnState[1]" show-overflow-tooltip>
            <template slot-scope="scope">
              <div v-if="scope.row.dataDt">{{ timeFormat(scope.row.dataDt) }}</div>
              <div v-else>-</div>
            </template>
          </el-table-column>
          <el-table-column prop="versionNum" label="当前版本号" v-if="columnState[2]"></el-table-column>
          <el-table-column prop="orgCd" label="机构" v-if="columnState[3]"></el-table-column>
          <el-table-column prop="industryCd" label="行业" v-if="columnState[4]"></el-table-column>
          <el-table-column prop="custNo" label="客户编号" v-if="columnState[5]"></el-table-column>
          <el-table-column prop="prdCd" label="产品" v-if="columnState[6]" show-overflow-tooltip></el-table-column>
          <el-table-column prop="sbjtCd" label="科目" v-if="columnState[7]"></el-table-column>
          <el-table-column prop="sbjtTp" label="业务类型" v-if="columnState[8]" show-overflow-tooltip></el-table-column>
          <el-table-column prop="ccyCd" label="币种" v-if="columnState[9]" show-overflow-tooltip></el-table-column>
          <el-table-column
            prop="curBal"
            label="当前余额"
            v-if="columnState[10]"
            show-overflow-tooltip
            :formatter="row => (row.curBal * 1).toFixed(6)"
          ></el-table-column>
          <el-table-column
            prop="matuFlg"
            label="有无到期日标识"
            v-if="columnState[11]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="lastRpricBal"
            label="上次重定价余额"
            :formatter="row => (row.lastRpricBal * 1).toFixed(6)"
            v-if="columnState[12]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="origAmt"
            label="原始余额"
            :formatter="row => (row.origAmt * 1).toFixed(6)"
            v-if="columnState[13]"
            show-overflow-tooltip
          ></el-table-column>

          <el-table-column
            prop="pmtBal"
            label="支付金额"
            :formatter="row => (row.pmtBal * 1).toFixed(6)"
            v-if="columnState[14]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column prop="startDt" label="起息日" v-if="columnState[15]" show-overflow-tooltip></el-table-column>
          <el-table-column prop="matuDt" label="到期日" v-if="columnState[16]" show-overflow-tooltip></el-table-column>
          <el-table-column prop="orgTerm" label="原始期限" v-if="columnState[17]" show-overflow-tooltip></el-table-column>
          <el-table-column
            prop="overdueTerm"
            label="逾期期限"
            v-if="columnState[18]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="execRate"
            label="对客利率"
            v-if="columnState[19]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="acruIntstBas"
            label="计息基础代码"
            v-if="columnState[20]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="execRateCd"
            label="利率代码"
            v-if="columnState[21]"
            show-overflow-tooltip
          ></el-table-column>

          <el-table-column
            prop="fltTpCd"
            label="浮动类型代码"
            v-if="columnState[22]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="fltRatio"
            label="浮动比例"
            v-if="columnState[23]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="fltMargin"
            label="浮动利差"
            v-if="columnState[24]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="lastExecRateChangeDt"
            label="最新执行利率变更日期"
            v-if="columnState[25]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column prop="pmtFreq" label="结息频率" v-if="columnState[26]" show-overflow-tooltip></el-table-column>
          <el-table-column
            prop="rateTp"
            label="利率类型代码"
            v-if="columnState[27]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="rpricDtAdjstTp"
            label="重定价类型代码"
            v-if="columnState[28]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="lastRpricDt"
            label="上次重定价日期"
            v-if="columnState[29]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="nextRepricDt"
            label="下次重定价日期"
            v-if="columnState[30]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="repriceFreq"
            label="重定价频率"
            v-if="columnState[31]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column prop="pmtTp" label="支付类型代码" v-if="columnState[32]" show-overflow-tooltip></el-table-column>
          <el-table-column
            prop="lastPrinPmtDt"
            label="上次支付日"
            v-if="columnState[33]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="nextPrinPmtDt"
            label="下次支付日"
            v-if="columnState[34]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column prop="payFreq" label="支付频率" v-if="columnState[35]" show-overflow-tooltip></el-table-column>
          <el-table-column
            prop="bizRatingCd"
            label="业务评级代码"
            v-if="columnState[36]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="custCateCd"
            label="客户类别代码"
            v-if="columnState[37]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column prop="chnlNm" label="渠道" v-if="columnState[38]" show-overflow-tooltip></el-table-column>
          <el-table-column prop="bizNo" label="业务编号" v-if="columnState[39]" show-overflow-tooltip></el-table-column>
          <el-table-column prop="isOdue" label="逾期标识" v-if="columnState[40]" show-overflow-tooltip></el-table-column>
          <el-table-column
            prop="earlyPmtAmt"
            label="提前还款金额"
            v-if="columnState[41]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="issuerCd"
            label="发行人代码"
            v-if="columnState[42]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="rateSensitiveFlg"
            label="利率敏感标识"
            v-if="columnState[43]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="instrumentTpCd"
            label="金融工具类型代码"
            v-if="columnState[44]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="costCtrTpCd"
            label="成本中心分类代码"
            v-if="columnState[45]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="isSbjtOdue"
            label="资产负债逾期标志"
            v-if="columnState[46]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="offshoreFlg"
            label="离岸标识"
            v-if="columnState[47]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column prop="sizeFlg" label="规模标识" v-if="columnState[48]" show-overflow-tooltip></el-table-column>
          <el-table-column prop="isAgmt" label="协定标识" v-if="columnState[49]" show-overflow-tooltip></el-table-column>
          <el-table-column
            prop="pmtPlanFlg"
            label="还款计划表标识"
            v-if="columnState[50]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="incrementFlg"
            label="增量标识"
            v-if="columnState[51]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="lastRpricExecRate"
            label="上次重定价执行利率"
            v-if="columnState[52]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="nextmtAmt"
            label="下次支付金额"
            v-if="columnState[53]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="firstPrinPmtDt"
            label="首次还款日"
            v-if="columnState[54]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="billRate"
            label="票面利率"
            v-if="columnState[55]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="isVlid"
            label="数据有效性标识"
            v-if="columnState[56]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column prop="bizLineCd" label="条线" v-if="columnState[57]" show-overflow-tooltip></el-table-column>
          <el-table-column prop="area" label="区域" v-if="columnState[58]" show-overflow-tooltip></el-table-column>
          <el-table-column
            prop="outIntstIncExp"
            label="外部利息收支"
            v-if="columnState[59]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="lnPrePmtFlg"
            label="提前终止标示"
            v-if="columnState[60]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="elementChangeFlg"
            label="业务要素变更标志"
            v-if="columnState[61]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append1"
            label="备用字段1"
            v-if="columnState[62]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append2"
            label="备用字段2"
            v-if="columnState[62]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append3"
            label="备用字段3"
            v-if="columnState[63]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append4"
            label="备用字段4"
            v-if="columnState[64]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append5"
            label="备用字段5"
            v-if="columnState[65]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append6"
            label="备用字段6"
            v-if="columnState[66]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append7"
            label="备用字段7"
            v-if="columnState[67]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append8"
            label="备用字段8"
            v-if="columnState[68]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append9"
            label="备用字段9"
            v-if="columnState[69]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append10"
            label="备用字段10"
            v-if="columnState[70]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append11"
            label="备用字段11"
            v-if="columnState[71]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append12"
            label="备用字段12"
            v-if="columnState[72]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append13"
            label="备用字段13"
            v-if="columnState[73]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append14"
            label="备用字段14"
            v-if="columnState[74]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append15"
            label="备用字段15"
            v-if="columnState[75]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append16"
            label="备用字段16"
            v-if="columnState[76]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append17"
            label="备用字段17"
            v-if="columnState[77]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append18"
            label="备用字段18"
            v-if="columnState[78]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append19"
            label="备用字段19"
            v-if="columnState[79]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="append20"
            label="备用字段20"
            v-if="columnState[80]"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column prop="dataSrc" label="数据来源" v-if="columnState[81]" show-overflow-tooltip></el-table-column>
        </el-table>
        <pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="searchForm.page"
          :page-size="searchForm.size"
          @refresh="searchFunc"
          :total="total"
        ></pagination>
      </el-col>
    </el-row>
    <!-- 新增、编辑弹窗 -->
    <el-dialog v-dialogDrag :title="titleName" :visible.sync="amendFormDi" width="60%" top="2%">
      <amend-form ref="amendFormRef" 
      :amendFormData="amendFormData"
      @resultInff="resultInff"
      ></amend-form>
      <div slot="footer">
        <el-button @click="saveFunc"  v-if="operateType !=='3'" >确 定</el-button>
        <el-button @click="amendFormDi = false">取 消</el-button>
      </div>
    </el-dialog>

     <!-- 查看历史弹框 -->
    <el-dialog v-dialogDrag :title="zipperTitleName" 
    :visible.sync="amendZipperDi" width="60%" top="2%">
      <amend-zipper ref="amendZipperRef" 
      :amendZipperData="amendZipperData"
      @historyResys="historyResys"
      ></amend-zipper>
    </el-dialog>
  </div>
</template>

<script>
import moment from "moment";
import { positionAmend } from "@/api/index";
import amendForm from "./positionAmendForm";
import amendZipper from './positionAmendZipperIndex';
export default {
  components: {
    amendForm,
    amendZipper
  },
  data() {
    return {
      operateType: "0",
      total: 0,
      searchForm: {
        page: 1,
        size: 15
      },
      checkList: [],
      textData: [
        { prop: "acctNo", label: "账号", disabled: true, checked: true },
        { prop: "dataDt", label: "数据日期", disabled: true, checked: true },
        {
          prop: "versionNum",
          label: "当前版本号",
          disabled: true,
          checked: true
        },
        { prop: "orgCd", label: "机构", disabled: true, checked: true },
        { prop: "industryCd", label: "行业", disabled: true, checked: true },
        { prop: "custNo", label: "客户编号", disabled: true, checked: true },
        { prop: "prdCd", label: "产品", disabled: true, checked: true },
        { prop: "sbjtCd", label: "科目", disabled: true, checked: true },
        { prop: "sbjtTp", label: "业务类型", disabled: true, checked: true },
        { prop: "ccyCd", label: "币种", disabled: true, checked: true },
        { prop: "curBal", label: "当前余额", disabled: true, checked: true },
        {
          prop: "matuFlg",
          label: "有无到期日标志",
          disabled: true,
          checked: true
        },
        { prop: "lastRpricBal", label: "上次重定价余额", disabled: true },
        { prop: "origAmt", label: "原始余额", disabled: true },
        { prop: "pmtBal", label: "支付金额", disabled: true },
        { prop: "startDt", label: "起息日", disabled: true },
        { prop: "matuDt", label: "到期日", disabled: true },
        { prop: "orgTerm", label: "原始期限", disabled: true },
        { prop: "overdueTerm", label: "逾期期限", disabled: true },
        { prop: "execRate", label: "对客利率", disabled: true },
        { prop: "acruIntstBas", label: "计息基础代码", disabled: true },
        { prop: "execRateCd", label: "利率代码", disabled: true },
        { prop: "fltTpCd", label: "浮动类型代码", disabled: true },
        { prop: "fltRatio", label: "浮动比例", disabled: true },
        { prop: "fltMargin", label: "浮动利差", disabled: true },
        {
          prop: "lastExecRateChangeDt",
          label: "最新执行利率变更日期",
          disabled: true
        },
        { prop: "pmtFreq", label: "结息频率", disabled: true },
        { prop: "rateTp", label: "利率类型代码", disabled: true },
        { prop: "rpricDtAdjstTp", label: "重定价类型代码", disabled: true },
        { prop: "lastRpricDt", label: "上次重定价日期", disabled: true },
        { prop: "nextRepricDt", label: "下次重定价日期", disabled: true },
        { prop: "repriceFreq", label: "重定价频率", disabled: true },
        { prop: "pmtTp", label: "支付类型代码", disabled: true },
        { prop: "lastPrinPmtDt", label: "上次支付日", disabled: true },
        { prop: "nextPrinPmtDt", label: "下次支付日", disabled: true },
        { prop: "payFreq", label: "支付频率", disabled: true },
        { prop: "bizRatingCd", label: "业务评级代码", disabled: true },
        { prop: "custCateCd", label: "客户类别代码", disabled: true },
        { prop: "chnlNm", label: "渠道", disabled: true },
        { prop: "bizNo", label: "业务编号", disabled: true },
        { prop: "isOdue", label: "逾期标识", disabled: true },
        { prop: "earlyPmtAmt", label: "提前还款金额", disabled: true },
        { prop: "issuerCd", label: "发行人代码", disabled: true },
        { prop: "rateSensitiveFlg", label: "利率敏感标志", disabled: true },
        { prop: "instrumentTpCd", label: "金融工具类型代码", disabled: true },
        { prop: "costCtrTpCd", label: "成本中心分类代码", disabled: true },
        { prop: "isSbjtOdue", label: "资产负债逾期标志", disabled: true },
        { prop: "offshoreFlg", label: "离岸标识", disabled: true },
        { prop: "sizeFlg", label: "规模标识", disabled: true },
        { prop: "isAgmt", label: "协定标识", disabled: true },
        { prop: "pmtPlanFlg", label: "还款计划表标志", disabled: true },
        { prop: "incrementFlg", label: "增量标志", disabled: true },
        {
          prop: "lastRpricExecRate",
          label: "上次重订价执行利率",
          disabled: true
        },
        { prop: "nextmtAmt", label: "下次支付金额", disabled: true },
        { prop: "firstPrinPmtDt", label: "首次还款日", disabled: true },
        { prop: "billRate", label: "票面利率", disabled: true },
        { prop: "isVlid", label: "数据有效性标识", disabled: true },
        { prop: "bizLineCd", label: "条线", disabled: true },
        { prop: "area", label: "区域", disabled: true },
        { prop: "outIntstIncExp", label: "外部利息收支", disabled: true },
        { prop: "lnPrePmtFlg", label: "提前终止标示", disabled: true },
        { prop: "elementChangeFlg", label: "业务要素变更标志", disabled: true },
        { prop: "append1", label: "备用字段1", disabled: true },
        { prop: "append2", label: "备用字段2", disabled: true },
        { prop: "append3", label: "备用字段3", disabled: true },
        { prop: "append4", label: "备用字段4", disabled: true },
        { prop: "append5", label: "备用字段5", disabled: true },
        { prop: "append6", label: "备用字段6", disabled: true },
        { prop: "append7", label: "备用字段7", disabled: true },
        { prop: "append8", label: "备用字段8", disabled: true },
        { prop: "append9", label: "备用字段9", disabled: true },
        { prop: "append10", label: "备用字段10", disabled: true },
        { prop: "append11", label: "备用字段11", disabled: true },
        { prop: "append12", label: "备用字段12", disabled: true },
        { prop: "append13", label: "备用字段13", disabled: true },
        { prop: "append14", label: "备用字段14", disabled: true },
        { prop: "append15", label: "备用字段15", disabled: true },
        { prop: "append16", label: "备用字段16", disabled: true },
        { prop: "append17", label: "备用字段17", disabled: true },
        { prop: "append18", label: "备用字段18", disabled: true },
        { prop: "append19", label: "备用字段19", disabled: true },
        { prop: "append20", label: "备用字段20", disabled: true },
        { prop: "dataSrc", label: "数据来源", disabled: true }
      ],
      tableData: [],
      titleName: "",
      amendFormDi: false,
      amendFormData: {},
      //历史数据
      amendZipperDi:false,
      amendZipperData:"",
      zipperTitleName:"查看历史",
    };
  },
  created() {
    this.searchFunc();
  },
  mounted() {},
  computed: {
    columnState() {
      let arr = [],
        arr1 = this.textData,
        arr2 = this.checkList;
      for (let i = 0; i < arr1.length; i++) {
        let flg = false;
        for (let j = 0; j < arr2.length; j++) {
          if (arr1[i].label === arr2[j]) {
            flg = true;
          }
        }
        arr.push(flg);
      }
      return arr;
    }
  },
  methods: {
    searchFunc() {
      let params = { ...this.searchForm };
      console.log(params, "params");
      positionAmend.findAll(params).then(res => {
        if (res.code == 200) {
          this.tableData = res.rows;
          this.total = res.total;
        } else {
          this.$message.error("数据查询失败");
        }
      });
    },
    addOrEditFunc(val) {
      this.operateType = val;
      switch (val) {
        case "1":
          this.titleName = "新增数据补录";
          break;
        case "2":
          this.titleName = "编辑数据补录";
          break;
        case "3":
          this.titleName = "查看数据补录";
          break;
      }

      let selections = this.$refs.multipleTable.selection;
      let id = "";
      if (val != "1") {
        if (selections.length == 0) {
          return this.$message.warning("请选择一条数据操作");
        }
        id = selections[0].acctNo;
      }
      this.amendFormDi = true;
      this.amendFormData = {
        operateType: val,
        acctNo: id
      };
     
      this.$nextTick(() => {
        this.$refs.amendFormRef.initAmend();
      });
    },
    //保存
    saveFunc() {   
      this.$refs.amendFormRef.saveAmendData();
     
    },
    //保存成功 从新查询页面
    resultInff(){
         this.amendFormDi = false;
         this.searchFunc();   
    },
    //重新使用历史数据
    historyResys(val){
         this.amendZipperDi = false;
         if(val =='0'){
            this.searchFunc();    
         }
        
    },
    //删除
    delFunc() {
      //获取选中删除数据
      debugger;
      let selections = this.$refs.multipleTable.selection;
      if (selections.length == 0) {
        return this.$message.warning("请选择一条数据进行操作!");
      }
      let acctNos = selections.map(v => {
        return v.acctNo;
      });

      let params = { ids: acctNos };
      positionAmend.remove(params).then(res => {
        if (res.code == 200) {
          this.$message.success(res.message);
          this.searchFunc();
        } else {
          this.$message.error(res.message);
        }
      });
    },
    rowChecked(row) {
      if (this.$refs.multipleTable) {
        this.$refs.multipleTable.clearSelection();
      }
      this.$refs.multipleTable.toggleRowSelection(row);
    },
    //导出
    exportExcel(val) {
      //判断是模板还是数据
      let params = {};
      if (val == "1") {
        params = {
          hasTemplete: true
        };
      } else if (val == "2") {
        //判断是否勾选数据
        let selections = this.$refs.multipleTable.selection;
        if (selections.length > 0) {
          let selectedData = selections.map(v => {
            return v.acctNo;
          });
          params = {
            hasTemplete: false,
            selectedData: selectedData
          };
        } else {
          params = {
            hasTemplete: false,
            acctNo: this.searchForm.acctNo
          };
        }
      }

      positionAmend.exportFile(params).then(response => {
        if (response) {
          console.log(response, "response205");
          var filename = decodeURI(
            response.headers["content-disposition"]
          ).split("=")[1];
          //  var filename = "分摊动因数据展示.xlsx"
          var blob = new Blob([response.data], {
            type: "application/vnd.ms-excel;charset=utf-8"
          });
          if (window.navigator.msSaveOrOpenBlob) {
            navigator.msSaveBlob(blob, filename);
          } else {
            var downloadElement = document.createElement("a");
            var href = window.URL.createObjectURL(blob); //创建下载的链接
            downloadElement.href = href;
            downloadElement.download = filename; //下载后文件名
            document.body.appendChild(downloadElement);
            downloadElement.click(); //点击下载
            document.body.removeChild(downloadElement); //下载完成移除元素
            window.URL.revokeObjectURL(href); //释放掉blob对象
          }
        } else {
          this.$message.error(res.message || "获取失败");
        }
      });
    },
    //事件转换
    timeFormat(val) {
      if (val) return moment(val).format("YYYY-MM-DD HH:mm:ss");
      else return "";
    },
    // 上传文件之前的钩子
    beforeUpload(file) {
      let name = file.name;
      let type = name.substring(name.lastIndexOf("."), name.length);
      if (type === ".xls" || type === ".xlsx") {
        return true;
      } else {
        this.$message.warning("只能选择xls或者xlsx格式的文件上传");
        return false;
      }
    },
    // 上传文件
    uploadFile(item) {
      let form = new FormData();
      // 文件对象
      form.append("excelFile", item.file);
      // 发送请求
      positionAmend.fileUpload(form).then(res => {
        if (res.code == 200) {
          this.$message.success(res.message);
        } else {
          this.$message.error(res.message);
        }
          this.$refs.upload.clearFiles();
      }).catch(err => {
          this.$refs.upload.clearFiles();
        });
    },
    //   点击行选中
    authorizeFor(row) {
      if (this.$refs.multipleTable) {
        this.$refs.multipleTable.clearSelection();
      }
      this.$refs.multipleTable.toggleRowSelection(row, true);
    },
    timeFormat(val) {
      if (val) return moment(val).format("YYYY-MM-DD");
      else return "";
    },
    //页码值改变
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.searchForm.size = val;
      this.searchFunc();
    },
    //当前页改变
    handleCurrentChange(val) {
      this.searchForm.page = val;
      console.log(`当前页: ${val}`);
      this.searchFunc();
    },
    //查看历史  amendZipperData  multipleTable
    catHistory(){
            let selections = this.$refs.multipleTable.selection;
            if(selections.length !==1){
                return this.$message.warning("请选择一条数据进行操作!");
            }
            this.zipperTitleName = "查看历史"
            this.amendZipperData = selections[0].acctNo;
            this.amendZipperDi =true;
            this.$nextTick(()=>{
                      this.$refs.amendZipperRef.searchFunc();
            })
          
    },
  }
};
</script>

<style lang="scss" scoped >
</style>
